//
//  SHIYUNTabBarController.m
//  诗韵
//
//  Created by Song on 2017/12/25.
//  Copyright © 2017年 Song. All rights reserved.
//

#import "SHIYUNTabBarController.h"
#import "SHINavigationController.h"
//#import "SHIYUNViewController.h"
#import "ShouyeViewController.h"
#import "contactViewController.h"
#import "shisheViewController.h"
#import "jishiViewController.h"
//#import "ViewController.h"
#import "SHITabBar.h"

@interface SHIYUNTabBarController ()

@end

@implementation SHIYUNTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 文字属性
    UITabBarItem *item = [UITabBarItem appearance];
    // 普通状态
    NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary];
    normalAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    normalAttrs[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    [item setTitleTextAttributes:normalAttrs forState:UIControlStateNormal];
    // 选中状态下
    NSMutableDictionary *selectAttrs = [NSMutableDictionary dictionary];
    selectAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    [item setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];
    
    // 添加子控制器
    [self setupChildViewController:[[SHINavigationController alloc] initWithRootViewController:[[ShouyeViewController alloc] init]] title:@"首页" image:@"shouye" selectedImage:@"shouye_selected"];
    [self setupChildViewController:[[SHINavigationController alloc] initWithRootViewController:[[contactViewController alloc] init]] title:@"联系人" image:@"lianxiren" selectedImage:@"lianxiren_selected"];
    [self setupChildViewController:[[SHINavigationController alloc] initWithRootViewController:[[shisheViewController alloc] init]] title:@"诗社" image:@"shishe" selectedImage:@"shishe_selected"];
    [self setupChildViewController:[[SHINavigationController alloc] initWithRootViewController:[[jishiViewController alloc] init]] title:@"集市" image:@"jishi" selectedImage:@"jishi_selected"];
    
    // 更换 tabbar
//    [self setValue:[[SHITabBar alloc] init] forKey:@"tabBar"];
    
//    self.tabBarItem.imageInsets = UIEdgeInsetsMake(10, 2, 2, 2);
    
}

-(void)setupChildViewController:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage {
    vc.tabBarItem.title = title;
    if (image.length) {
        vc.tabBarItem.image = [UIImage imageNamed:image];
        vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    }
    [self addChildViewController:vc];
}



@end
